package com.yellowpage.ndc.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.ndc.data.Classification;
import com.yellowpage.ndc.dao.ClassificationDao;

public class ClassificationServiceImpl extends BaseServiceImpl implements ClassificationService {
	  private ClassificationDao classificationDao;
	
	  public void setClassificationDao(ClassificationDao classificationDao) {
		  this.classificationDao = classificationDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public Classification getClassification(Long id){
	      return classificationDao.get(id);
	  }
	  
    public List<Classification> getAllClassification(){
        return classificationDao.getAll();
    }
    
    public List<Map> queryClassificationByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.LINE , a.CLASS_ID , a.ENG_NAME , a.PY_NAME , a.BX_NAME , a.NOTE , a.NAME , a.STATUS , a.CODE    " +
				"  FROM db_ndc.CLASSIFICATION a WHERE 1=1 ")
				    			.addCondition(" and LINE = :line ")
							    			.addCondition(" and CLASS_ID = :classId ")
							    			.addCondition(" and ENG_NAME = :engName ")
							    			.addCondition(" and PY_NAME = :pyName ")
							    			.addCondition(" and BX_NAME = :bxName ")
							    			.addCondition(" and NOTE = :note ")
							    			.addCondition(" and NAME = :name ")
							    			.addCondition(" and STATUS = :status ")
							    			.addCondition(" and CODE = :code "); 		    
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveClassification(Classification classification){
        classificationDao.save(classification);
    }
    
	  public void updateClassification(Classification classification){
	      classificationDao.update(classification);
	  }
	  
	  public void delete(List deleteList){
	      classificationDao.remove(deleteList);
	  }
	  
	  
	 
	
}	